ArcPad Scripting Object Model
RecordSet Example 2
Send Feedback
ArcPad Scripting Object Model Reference > ArcPad Scripting Samples > RecordSet Example 2

Glossary Item Box

Description

DeleteSelected deletes the selected feature.

VBScript Code

Copy Code
Sub DeleteSelected
  Dim objSelLayer, objRS
  'Get selected layer and index
  Set objSelLayer = Application.Map.SelectionLayer
  If objSelLayer Is Nothing Then
    MsgBox "Please select a feature!"
    Exit Sub
  End If
  'Get the RecordSet of the selected Layer
  Set objRS = objSelLayer.Records
  'Move to the selected feature
  objRS.Bookmark = Application.Map.SelectionBookmark
  'Delete the selected feature
  objRS.Delete
  'Update the RecordSet
  objRS.Update
  'Refresh the Map
  Application.Map.Refresh(True)
End Sub
 
Sub DeleteSelectedToLast
  Dim objSelLayer, objRS
  'Get selected layer and index
  Set objSelLayer = Application.Map.SelectionLayer
  If objSelLayer Is Nothing Then
    MsgBox "Please select a feature!"
    Exit Sub
  End If
  'Get the RecordSet of the selected Layer
  Set objRS = objSelLayer.Records
  'Move to the selected feature
  objRS.Bookmark = Application.Map.SelectionBookmark
  'Delete all features from the selected feature to the last feature added
  While Not objRS.EOF
    objRS.Delete
    'Update the RecordSet after each deletion
    objRS.Update
    objRS.MoveNext
  Wend
  'Refresh the Map
  Application.Map.Refresh(True)
End Sub
Sub DeleteSelectedToFirst
  Dim objSelLayer, objRS
  'Get selected layer and index
  Set objSelLayer = Application.Map.SelectionLayer
  If objSelLayer Is Nothing Then
    MsgBox "Please select a feature!"
    Exit Sub
  End If
  'Get the RecordSet of the selected Layer
  Set objRS = objSelLayer.Records
  'Move to the selected feature
  objRS.Bookmark = Application.Map.SelectionBookmark
  'Delete all features from the selected feature to the first feature added
  While Not objRS.BOF
    objRS.Delete
    'Update the RecordSet after each deletion
    objRS.Update
    objRS.MovePrevious
  Wend
  'Refresh the Map
  Application.Map.Refresh(True)
End Sub
©2012. All Rights Reserved.